package com.sun.springbootspi.service.impl;

import com.sun.springbootspi.service.Logger;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @version 1.0
 * @Package: com.sun.springbootspi.service.impl
 * @ClassName: ConsoleLogger
 * @Author: sgq
 * @Date: 2025/1/1 18:21
 * @Description: 文件日志记录器实现
 */
public class FileLogger implements Logger {
    private static final String LOG_FILE_PATH = "application.log";

    @Override
    public void log(String message) {
        try (PrintWriter writer = new PrintWriter(new FileWriter(LOG_FILE_PATH, true))) {
            writer.println(message);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
